#include <iostream>
#include <vector>


using namespace std;
typedef vector<int> IntList;
typedef vector<IntList> IntArea;

int main()
{
    IntArea vec;
	int num=0,j=0,i=0,t=0;
	IntList temp,tt;
	cin>>num;
	for(i=0;i<num;i++)
	{
		for(j=0;j<=i;j++)
		{
			cin>>t;
			temp.push_back(t);
		}
		vec.push_back(temp);
		temp.clear();
		j=0;
	}
	temp=vec[num-1];
	for(int k=num-2;k>0;k--)
	{
		for(int i=0;i<=k;i++)
		{
			tt.push_back((vec[k][i]+temp[i])>(vec[k][i]+temp[i+1])?(vec[k][i]+temp[i]):(vec[k][i]+temp[i+1]));
		}
		temp=tt;
		tt.clear();
	}
	cout<<vec[0][0]+(temp[0]>temp[1]?temp[0]:temp[1])<<endl;
	return 0;
}